﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <!--## Button ##-->

    <LinearGradientBrush x:Key="ButtonBackground"
                         StartPoint="0,0"
                         EndPoint="1,0">
        <GradientStop Color="Silver"
                      Offset="0" />
        <GradientStop Color="#eeeeee"
                      Offset="1" />
    </LinearGradientBrush>

    <Style TargetType="Button">
        <Setter Property="Background"
                Value="{StaticResource ButtonBackground}" />
        <Setter Property="BorderBrush"
                Value="Gray" />
        <Setter Property="ClipToBounds"
                Value="true" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid Name="MainGrid"
                          RenderTransformOrigin="0.5,0.5">
                        <Grid.RenderTransform>
                            <ScaleTransform />
                        </Grid.RenderTransform>
                        <Rectangle Name="MainRectangle"
                                   Grid.ColumnSpan="3"
                                   Grid.RowSpan="3"
                                   Fill="{TemplateBinding Background}"
                                   RadiusX="3"
                                   RadiusY="3" />
                        <Rectangle Name="rectangleWhiteBackground"
                                   Grid.ColumnSpan="3"
                                   Grid.RowSpan="3"
                                   Fill="#60ffffff"
                                   RadiusX="3"
                                   RadiusY="3" />

                        <Rectangle Name="rectangleLeft"
                                   Width="20"
                                   HorizontalAlignment="Left"
                                   RadiusX="3"
                                   RadiusY="3">
                            <Rectangle.Fill>
                                <RadialGradientBrush GradientOrigin="0,0.2"
                                                     Center="0,0.2"
                                                     RadiusX="0.3"
                                                     RadiusY="1"
                                                     Opacity="1">
                                    <GradientStop Color="White"
                                                  Offset="0" />
                                    <GradientStop Color="Transparent"
                                                  Offset="1" />
                                </RadialGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>

                        <Rectangle Name="rectangleTop"
                                   Height="20"
                                   VerticalAlignment="Top"
                                   RadiusX="3"
                                   RadiusY="3">
                            <Rectangle.Fill>
                                <RadialGradientBrush GradientOrigin="0.4,0"
                                                     Center="0.4,0"
                                                     RadiusX="1.2"
                                                     RadiusY="0.3"
                                                     Opacity="0.9">
                                    <GradientStop Color="White"
                                                  Offset="0" />
                                    <GradientStop Color="Transparent"
                                                  Offset="1" />
                                </RadialGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>

                        <Rectangle Name="rectangleRight"
                                   Width="20"
                                   HorizontalAlignment="Right"
                                   RadiusX="3"
                                   RadiusY="3">
                            <Rectangle.Fill>
                                <RadialGradientBrush GradientOrigin="1,0.65"
                                                     Center="1,0.65"
                                                     RadiusX="0.3"
                                                     RadiusY="0.7"
                                                     Opacity="0.8">
                                    <GradientStop Color="#44222222"
                                                  Offset="0" />
                                    <GradientStop Color="Transparent"
                                                  Offset="1" />
                                </RadialGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>

                        <Rectangle Name="rectangleBottom"
                                   Height="20"
                                   VerticalAlignment="Bottom"
                                   RadiusX="3"
                                   RadiusY="3">
                            <Rectangle.Fill>
                                <RadialGradientBrush GradientOrigin="0.5,1"
                                                     Center="0.5,1"
                                                     RadiusX="1.2"
                                                     RadiusY="0.3"
                                                     Opacity="0.8">
                                    <GradientStop Color="#44222222"
                                                  Offset="0" />
                                    <GradientStop Color="Transparent"
                                                  Offset="1" />
                                </RadialGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>

                        <Rectangle Grid.ColumnSpan="3"
                                   Grid.RowSpan="3"
                                   Stroke="{TemplateBinding BorderBrush}"
                                   RadiusX="3"
                                   RadiusY="3" />

                        <ContentPresenter Margin="12,6,12,6" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused"
                                 Value="True">
                            <Setter TargetName="rectangleWhiteBackground"
                                    Property="Fill"
                                    Value="Transparent" />
                        </Trigger>
                        <Trigger Property="IsMouseOver"
                                 Value="True">
                            <Setter TargetName="rectangleWhiteBackground"
                                    Property="Fill"
                                    Value="Transparent" />
                        </Trigger>
                        <Trigger Property="IsPressed"
                                 Value="True">
                            <Setter TargetName="rectangleTop"
                                    Property="Fill">
                                <Setter.Value>
                                    <RadialGradientBrush GradientOrigin="0.4,0"
                                                         Center="0.4,0"
                                                         RadiusX="1.2"
                                                         RadiusY="0.3"
                                                         Opacity="0.9">
                                        <GradientStop Color="#44222222"
                                                      Offset="0" />
                                        <GradientStop Color="Transparent"
                                                      Offset="1" />
                                    </RadialGradientBrush>
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="rectangleRight"
                                    Property="Fill"
                                    Value="Transparent" />
                            <Setter TargetName="rectangleBottom"
                                    Property="Fill"
                                    Value="Transparent" />
                            <Setter TargetName="rectangleLeft"
                                    Property="Fill">
                                <Setter.Value>
                                    <RadialGradientBrush GradientOrigin="0,0.2"
                                                         Center="0,0.2"
                                                         RadiusX="0.3"
                                                         RadiusY="1"
                                                         Opacity="1">
                                        <GradientStop Color="#44222222"
                                                      Offset="0" />
                                        <GradientStop Color="Transparent"
                                                      Offset="1" />
                                    </RadialGradientBrush>
                                </Setter.Value>
                            </Setter>
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MainGrid"
                                                         Storyboard.TargetProperty="RenderTransform.ScaleX"
                                                         From="1"
                                                         To="0.95"
                                                         Duration="0:0:0.15" />
                                        <DoubleAnimation Storyboard.TargetName="MainGrid"
                                                         Storyboard.TargetProperty="RenderTransform.ScaleY"
                                                         From="1"
                                                         To="0.95"
                                                         Duration="0:0:0.15" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MainGrid"
                                                         Storyboard.TargetProperty="RenderTransform.ScaleX"
                                                         From="0.95"
                                                         To="1"
                                                         Duration="0:0:0.15" />
                                        <DoubleAnimation Storyboard.TargetName="MainGrid"
                                                         Storyboard.TargetProperty="RenderTransform.ScaleY"
                                                         From="0.95"
                                                         To="1"
                                                         Duration="0:0:0.15" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--## Item (base style for any ItemsControl item) ##-->

    <Style x:Key="ItemStyle"
           TargetType="ContentControl">
        <Setter Property="Background">
            <Setter.Value>
                <LinearGradientBrush EndPoint="0,1">
                    <GradientStop Color="#FFFFFFFF"
                                  Offset="0" />
                    <GradientStop Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}"
                                  Offset="1" />
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="BorderBrush"
                Value="#FF808080" />
        <Setter Property="BorderThickness"
                Value="1" />
        <Setter Property="DockPanel.Dock"
                Value="Top" />
        <Setter Property="Margin"
                Value="0,1,0,1" />
        <!--Setter Property="TextBox.TextAlignment" Value="Center" /-->
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ContentControl">
                    <Grid>
                        <Rectangle Name="SelectedHighlight"
                                   Fill="{TemplateBinding Background}"
                                   Stroke="{TemplateBinding BorderBrush}"
                                   RadiusX="2"
                                   RadiusY="2"
                                   Opacity="0" />
                        <Rectangle Name="HighlightCanvas"
                                   Fill="{TemplateBinding Background}"
                                   Stroke="{TemplateBinding BorderBrush}"
                                   RadiusX="2"
                                   RadiusY="2"
                                   Opacity="0" />
                        <ContentPresenter Margin="4,3,4,3" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Selector.IsSelected"
                                 Value="True">
                            <Setter Property="Opacity"
                                    TargetName="SelectedHighlight"
                                    Value="1" />
                        </Trigger>
                        <Trigger Property="IsMouseOver"
                                 Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation From="0"
                                                         To="1"
                                                         Duration="0:0:0.15"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Storyboard.TargetName="HighlightCanvas" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation From="1"
                                                         To="0"
                                                         Duration="0:0:0.15"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Storyboard.TargetName="HighlightCanvas" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--## ComboBox ##-->

    <Style TargetType="ComboBox">
        <Setter Property="Background"
                Value="#FFFFFFFF" />
        <Setter Property="BorderBrush"
                Value="#FF808080" />
        <Setter Property="Padding"
                Value="10,0,0,0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBox">
                    <Grid Name="MainGrid">
                        <Popup Name="PART_Popup"
                               AllowsTransparency="true"
                               Placement="Bottom"
                               IsOpen="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"
                               PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}">
                            <Grid Name="PopupCanvas"
                                  ClipToBounds="True"
                                  MaxHeight="{TemplateBinding MaxDropDownHeight}"
                                  MinWidth="{Binding ElementName=MainGrid, Path=ActualWidth}">
                                <Rectangle Fill="{TemplateBinding Background}"
                                           Stroke="{TemplateBinding BorderBrush}"
                                           Margin="0,-1,0,0" />
                                <ScrollViewer CanContentScroll="true">
                                    <ItemsPresenter Margin="5"
                                                    KeyboardNavigation.TabNavigation="Cycle"
                                                    KeyboardNavigation.DirectionalNavigation="Cycle"
                                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                    Grid.IsSharedSizeScope="true" />
                                </ScrollViewer>
                            </Grid>
                        </Popup>
                        <Rectangle Name="Background"
                                   Stroke="Transparent"
                                   Fill="{TemplateBinding Background}"
                                   RadiusX="3"
                                   RadiusY="3" />
                        <ContentPresenter IsHitTestVisible="false"
                                          Margin="{TemplateBinding Padding}"
                                          Content="{TemplateBinding SelectionBoxItem}"
                                          ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                          ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <Grid HorizontalAlignment="Right"
                              Width="20">
                            <Rectangle Name="rectangleArrow"
                                       RadiusX="3"
                                       RadiusY="3"
                                       Fill="{TemplateBinding BorderBrush}" />
                            <Path Data="M0,0L3.5,4 7,0z"
                                  Fill="White"
                                  HorizontalAlignment="Center"
                                  VerticalAlignment="Center" />
                            <Border Width="5"
                                    VerticalAlignment="Top"
                                    BorderThickness="1,0,0,0"
                                    BorderBrush="{TemplateBinding BorderBrush}" />
                        </Grid>
                        <Rectangle Width="20"
                                   HorizontalAlignment="Left"
                                   RadiusX="3"
                                   RadiusY="3">
                            <Rectangle.Fill>
                                <RadialGradientBrush Center="0,0.2"
                                                     RadiusX="0.3"
                                                     RadiusY="1"
                                                     GradientOrigin="0,0.2"
                                                     Opacity="1">
                                    <RadialGradientBrush.GradientStops>
                                        <GradientStop Color="#FFFFFFFF"
                                                      Offset="0" />
                                        <GradientStop Color="#00FFFFFF"
                                                      Offset="1" />
                                    </RadialGradientBrush.GradientStops>
                                </RadialGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <Rectangle Height="20"
                                   VerticalAlignment="Top"
                                   RadiusX="3"
                                   RadiusY="3">
                            <Rectangle.Fill>
                                <RadialGradientBrush Center="0.4,0"
                                                     RadiusX="1.2"
                                                     RadiusY="0.3"
                                                     GradientOrigin="0.4,0"
                                                     Opacity="0.9">
                                    <RadialGradientBrush.GradientStops>
                                        <GradientStop Color="#FFFFFFFF"
                                                      Offset="0" />
                                        <GradientStop Color="#00FFFFFF"
                                                      Offset="1" />
                                    </RadialGradientBrush.GradientStops>
                                </RadialGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <Rectangle HorizontalAlignment="Right"
                                   Width="20"
                                   RadiusX="3"
                                   RadiusY="3">
                            <Rectangle.Fill>
                                <RadialGradientBrush Center="1,0.65"
                                                     RadiusX="0.3"
                                                     RadiusY="0.7"
                                                     GradientOrigin="1,0.65"
                                                     Opacity="0.8">
                                    <RadialGradientBrush.GradientStops>
                                        <GradientStop Color="#44222222"
                                                      Offset="0" />
                                        <GradientStop Color="#00FFFFFF"
                                                      Offset="1" />
                                    </RadialGradientBrush.GradientStops>
                                </RadialGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <Rectangle VerticalAlignment="Bottom"
                                   Height="20"
                                   RadiusX="3"
                                   RadiusY="3">
                            <Rectangle.Fill>
                                <RadialGradientBrush Center="0.55,1"
                                                     RadiusX="0.95"
                                                     RadiusY="0.3"
                                                     GradientOrigin="0.55,1"
                                                     Opacity="0.8">
                                    <RadialGradientBrush.GradientStops>
                                        <GradientStop Color="#44222222"
                                                      Offset="0" />
                                        <GradientStop Color="#00FFFFFF"
                                                      Offset="1" />
                                    </RadialGradientBrush.GradientStops>
                                </RadialGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <Rectangle RadiusX="3"
                                   RadiusY="3"
                                   Fill="#00FFFFFF"
                                   Stroke="{TemplateBinding BorderBrush}" />
                        <ToggleButton IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
                            <ToggleButton.Style>
                                <Style TargetType="ToggleButton">
                                    <Setter Property="Background"
                                            Value="#00FFFFFF" />
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="ToggleButton">
                                                <Rectangle Fill="Transparent" />
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </ToggleButton.Style>
                        </ToggleButton>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver"
                                 Value="True">
                            <Setter Property="Opacity"
                                    TargetName="rectangleArrow"
                                    Value="0.65" />
                        </Trigger>
                        <Trigger Property="HasItems"
                                 Value="False">
                            <Setter Property="MinHeight"
                                    TargetName="PopupCanvas"
                                    Value="100" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="ComboBoxItem"
           BasedOn="{StaticResource ItemStyle}" />

    <!--## ListBox ##-->

    <Style TargetType="ListBox">
        <Setter Property="Background"
                Value="#FFFFFFFF" />
        <Setter Property="BorderBrush"
                Value="#FF808080" />
        <Setter Property="BorderThickness"
                Value="1" />
        <Setter Property="ClipToBounds"
                Value="True" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <DockPanel />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBox">
                    <Grid>
                        <Border CornerRadius="3"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}" />
                        <Rectangle Name="TopShadow"
                                   Stroke="#00FFFFFF"
                                   Height="8"
                                   VerticalAlignment="Top"
                                   RadiusX="3"
                                   RadiusY="3">
                            <Rectangle.Fill>
                                <LinearGradientBrush StartPoint="0,0"
                                                     EndPoint="0,1">
                                    <GradientStop Color="#33000000"
                                                  Offset="0" />
                                    <GradientStop Color="#00FFFFFF"
                                                  Offset="0.85" />
                                </LinearGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <Rectangle Name="LeftShadow"
                                   Stroke="#00FFFFFF"
                                   Width="8"
                                   HorizontalAlignment="Left"
                                   RadiusX="3"
                                   RadiusY="3">
                            <Rectangle.Fill>
                                <LinearGradientBrush StartPoint="0,0"
                                                     EndPoint="1,0">
                                    <GradientStop Color="#33000000"
                                                  Offset="0" />
                                    <GradientStop Color="#00FFFFFF"
                                                  Offset="0.85" />
                                </LinearGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <ItemsPresenter Margin="4" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="BorderThickness"
                                 Value="0">
                            <Setter TargetName="TopShadow"
                                    Property="Visibility"
                                    Value="Collapsed" />
                            <Setter TargetName="LeftShadow"
                                    Property="Visibility"
                                    Value="Collapsed" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="ListBoxItem"
           BasedOn="{StaticResource ItemStyle}" />

    <!--## TextBox ##-->

    <Style TargetType="TextBox"
           BasedOn="{StaticResource {x:Type TextBox}}">
        <Setter Property="Background"
                Value="White" />
        <Setter Property="BorderBrush"
                Value="Gray" />
        <Setter Property="HorizontalAlignment"
                Value="Left" />
        <Setter Property="Padding"
                Value="4" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TextBox">
                    <Grid>
                        <Rectangle Name="TextBoxBackground"
                                   Stroke="{TemplateBinding BorderBrush}"
                                   Fill="{TemplateBinding Background}"
                                   RadiusX="4"
                                   RadiusY="4" />
                        <Rectangle Name="TextBoxShadow"
                                   Height="8"
                                   VerticalAlignment="Top"
                                   Stroke="Transparent"
                                   RadiusX="4"
                                   RadiusY="4">
                            <Rectangle.Fill>
                                <LinearGradientBrush StartPoint="0,0"
                                                     EndPoint="0,1">
                                    <GradientStop Color="#40000000"
                                                  Offset="0" />
                                    <GradientStop Color="Transparent"
                                                  Offset="0.85" />
                                </LinearGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <Rectangle Name="ShadowLeft"
                                   Width="8"
                                   HorizontalAlignment="Left"
                                   Stroke="Transparent"
                                   RadiusX="4"
                                   RadiusY="4">
                            <Rectangle.Fill>
                                <LinearGradientBrush StartPoint="0,0"
                                                     EndPoint="1,0">
                                    <GradientStop Color="#40000000"
                                                  Offset="0" />
                                    <GradientStop Color="Transparent"
                                                  Offset="0.85" />
                                </LinearGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <ScrollViewer Name="PART_ContentHost"
                                      Padding="{TemplateBinding Padding}"
                                      SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--## ProgressBar ##-->

    <Style TargetType="ProgressBar">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ProgressBar">
                    <Grid>
                        <Rectangle Name="PART_Track"
                                   Stroke="DarkGray"
                                   StrokeThickness="2">
                            <Rectangle.Fill>
                                <LinearGradientBrush StartPoint="0,0"
                                                     EndPoint="1,0">
                                    <GradientStop Color="DarkGray"
                                                  Offset="0" />
                                    <GradientStop Color="White"
                                                  Offset="1" />
                                </LinearGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <Rectangle Name="PART_Indicator"
                                   HorizontalAlignment="Left"
                                   Margin="2">
                            <Rectangle.Fill>
                                <LinearGradientBrush StartPoint="0,0"
                                                     EndPoint="1,0">
                                    <GradientStop Color="Blue"
                                                  Offset="0" />
                                    <GradientStop Color="Black"
                                                  Offset="1" />
                                </LinearGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
